export default {
    data() {
        return {
            showBackTop: false
        }
    },
    mounted() {
        var flag = true
        window.addEventListener('scroll', () => {
            var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
            if (flag && scrollTop > 50) {
                flag = false
                this.showBackTop = true
            }
            if (scrollTop < 50) {
                flag = true
                this.showBackTop = false
            }
        })
    },
    methods: {
        back() { // 返回上一页
            this.$router.go(-1)
        },
        setSearchLocation() {
            this.$router.push({ path: '/index/search' })
        },
        swiperTo(swiper, activeIndex, len) {
            swiper.slideTo(activeIndex - len);
        },
        toTop() {
            document.documentElement.scrollTop = window.pageYOffset = document.body.scrollTop = 0
        }
    },
    filters: {
        Currency(val) { // 货币
            if (!val) return 0;
            return '¥' + parseFloat(val).toFixed(2)
        }
    }
}